#ifndef _SCENE_MAIN_H_
#define _SCENE_MAIN_H_
#include <list>
#include <random>
#include "Scene.h"
#include "Object.h"


class Game;

class SceneMain : public Scene
{
    public:
        SceneMain();
        ~SceneMain();
        
        void init() override;
        void update(float deltaTime) override;
        void render() override;
        void handleEvents(SDL_Event* event) override;
        void clean() override;

        void keyboardControls(float deltaTime);
        void shootPlayer();
        void shootEnemy(Enemy* enemy);
        void updatePlayer(float deltaTime); // 更新玩家  
        void updatePlayerProjectiles(float deltaTime); // 更新玩家子弹
        void updateEnemyProjectiles(float deltaTime); // 更新敌人子弹
        void renderPlayerProjectiles(); // 渲染玩家子弹
        void renderEnemyProjectiles(); // 渲染敌人子弹
        void spawEnemy(); // 生成敌机
        void updateEnemies(float deltaTime); // 更新敌机
        void renderEnemies(); // 渲染敌机
        SDL_FPoint getDirection(Enemy* enemy); // 获取敌机方向
        void enemyExplode(Enemy* enemy); 

        void updateExplosions(float deltaTime);
        void renderExplosions();

    private:
        Game &game;
        Player player;
        bool isDead = false; // 玩家是否死亡
        std::mt19937 gen; // 随机数生成器
        std::uniform_real_distribution<float> dis; // 随机数分布器

        // 创建每个物体的模版
        Enemy enemyTemplate;
        ProjectilePlayer projectilePlayerTemplate;
        ProjectileEnemy projectileEnemyTemplate;
        Explosion explosionTemplate;
        // 创建每个物体的容器
        std::list<Enemy*> enemies;
        std::list<ProjectilePlayer*> projectilesPlayer;
        std::list<ProjectileEnemy*> projectilesEnemy;
        std::list<Explosion*> explosions; 
        
};

#endif
